package com.txy.trigger.job;

import com.txy.domain.strategy.model.vo.StrategyAwardStockVO;
import com.txy.domain.strategy.service.IRaffleStock;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Slf4j
@Component
public class ScheduleJob {
    @Resource
    private IRaffleStock raffleStock;

    @Scheduled(cron = "0/5 * * * * ?")
    public void schedule() {
        try {
            log.info("定时任务执行");
            StrategyAwardStockVO fromQueue = raffleStock.getFromQueue();
            if (fromQueue == null) {
                return;
            }
            log.info("定时任务更新库存");
            raffleStock.updateAwardStock(fromQueue);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
        }
    }
}
